<?php
$header_msg = "edit blog ppst";
include_once('header.inc');
require_once('db.php');
?>

<div id="sample">
<script type="text/javascript" src="../nicEdit.js"></script>
<script type="text/javascript">
	bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
</script>

<?PHP
if ($_SESSION['USERGRP'] <= 2) {
//	echo "usergrp test passed";
	$sql = "SELECT * FROM `blogentries`
		WHERE `id`='".$_GET['blognumber']."'";
	$entrystatement = $eebsdb->query($sql)
		or die("sql query failed");
//	echo $entrystatement->rowCount();
	if ($entrystatement->rowCount() > 0) {
		$entrarr = $entrystatement->fetch();

//		echo "rowcount test passed";
//		print_r($_SESSION);

		if (($_SESSION['USERGRP'] == 2)
			|| (($_SESSION['USERGRP'] == 1)
				&& ($_SESSION['USER_ID'] == $entrarr['user_id']))) { //*/
//			echo "id test passed";
?>
<form method=post action="">
<P>Title:
	<textarea type=text name="entrytitle" value="<?PHP echo $entrarr['title']?>">
	</textarea></P>
<P>Comment:
	<textarea type=text name="entrytext" wrap=virtual>
	</textarea></P>
<input type="submit" value"submit">
</form>
/* <!--
			echo '<form method="post" action="readblog.php?blognumber='.$_GET['blognumber'].'">
				<label for="entrytitle">Title: </label>
					<input type="text" name="entrytitle" value="'.$entrarr['title'].'"><br/>
				<label for="entrytext">Entry: </label>
					<textarea NAME="entrytext" COLS=40 ROWS=5 WRAP="VIRTUAL">
					'.$entrarr['entry'].'
					</textarea><P><br/>
				<input type="submit" value="Submit edit"/>
			</form>';
?> -->
//*/
</div>
<?PHP
		}
	} else {
		echo "<P>that blog entry does not exist</P>";
		include_once('footer.inc');
	}
} else  { // here ends userland, start of guest land
?>
<BODY>
<P>
	only logged in users have read/write/edit permissions here, please
	<A HREF="login.php">log in</A> or <A HREF="login.php">register</A>.
</P>
<?php include_once('footer.inc'); }?>
